package com.example.color_test.utils;

import lombok.Data;

import java.io.Serializable;

/**
 *  枚举类
 */
public enum ResultCode implements Serializable {

    /**
     *  枚举信息
     */
    SUCCSSES(200,"操作成功",true),
    ERRO(500,"操作失败",false);

    /**
     * 错误码
     */
    private Integer code;
    /**
     * 提示信息
     */
    private String message;
    /**
     * 返回内容
     */
    private Object data;
    /**
     *  操作的状态 成功  true  失败  false
     */
    private boolean status;

    ResultCode(int code, String message, boolean status) {
        this.code = code;
        this.message = message;
        this.status = status;
    }

    public Object Result(){
        ResultNoData res = new ResultNoData();
        res.setCode(this.code);
        res.setMessage(this.message);
        res.setStatus(this.status);
        return res;
    }

    public Object Result(String message){
        ResultNoData res = new ResultNoData();
        res.setCode(this.code);
        res.setMessage(message);
        res.setStatus(this.status);
        return res;
    }
    public Object Result(String message,Object data){
        Result res = new Result();
        res.setCode(this.code);
        res.setMessage(message);
        res.setData(data);
        res.setStatus(this.status);
        return res;
    }

    public Object Result(Object data){
        Result res = new Result();
        res.setCode(this.code);
        res.setMessage(this.message);
        res.setData(data);
        res.setStatus(this.status);
        return res;
    }


    @Data
    class Result{
        private int code;
        private String message;
        private Object data;
        private boolean status;
    }

    @Data
    class ResultNoData{
        private int code;
        private String message;
        private boolean status;
    }
}
